package com.lzq.leetcode.lanqiao.th12;

import java.time.LocalDate;

public class s2 {

    public static void main(String[] args) {

        LocalDate date = LocalDate.of(2001, 1, 1);
        int ans = 0;
        while(date.getYear() <= 2021) {
            int year = date.getYear();
            int month = date.getMonthValue();
            int day = date.getDayOfMonth();
            int sum = getSum(year) + getSum(month) + getSum(day);
            int sqr = (int) Math.sqrt(sum);
            if (sqr * sqr == sum) {
                ++ans;
            }

            date = date.plusDays(1);
        }

        System.out.println(ans);
    }

    private static int getSum(int num) {
        int sum = 0;
        while (num != 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}
